
export default {
    isAndroid() {
        const u = navigator.userAgent;
        return u.indexOf('Android') > -1 || u.indexOf('Linux') > -1;
    },
    isIos() {
        const u = navigator.userAgent;
        return !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
    },
    isWx() {
        const u = navigator.userAgent.toLowerCase()
        return /micromessenger/.test(u);
    },
    /**
     * 获取url参数
     * @param key 
     */
    getUrlParam(key: string) {
        const reg = new RegExp(`(^|&)${key}=([^&]*)(&|$)`, 'i');
        const r = decodeURIComponent(location.search).substr(1).match(reg);
        if (r != null) {
            return decodeURI(r[2]);
        } else {
            return null;
        }
    },
    /**
     * 获取当前html文档所在目录
     */
    getDocumentPath() {
        const href = location.href;
        return href.substr(0, href.lastIndexOf('/') + 1);
    }
}
